package opera;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ken
 * Date: 2023-11-24
 * Time: 18:29
 */
public class FindOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入你要查找的书的名字");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        for(int i = 0 ; i <bookList.getUsedSize(); i++) {
           if(bookList.getBook(i).getName().equals(name)) {
               System.out.println("找到了这本书");
               System.out.println(bookList.getBook(i));
               return;
           }
        }
        System.out.println("没有找到");
    }
}
